Use awk to sum a column of numbers

1
2
3
4
5
cat count.txt | awk '{ sum+=$1} END {print sum}'
 
# or
 
numsum count.txt

Reference: http://www.commandlinefu.com/commands/view/1497/using-awk-to-sumcount-a-column-of-numbers.

Homepage
Comments

Hide Comments